var parameter = getRequest();
var clientName = parameter['clientname'];//参数名
var millName=parameter['millName'];
var Sdate=parameter['Sdate'];
var Edate=parameter['Edate'];
//var m_color=parameter['m_color'];
//var m_sehao=parameter['m_sehao'];
//var orderID=parameter['orderID'];


$(function () {

    //获取记录集
    getData();

    /**********************************************************/

    $('#waterdetai').datagrid({
        showFooter:true,
        onLoadSuccess: function (data) {
            data = data.rows;
            var qty = 0;
            var ps = 0;
            var ms = 0;

            for (let i = 0; i < data.length; i++) {
                qty += data[i].b_qty ? parseFloat(data[i].b_qty) : 0;
                ps += data[i].b_ps ? parseFloat(data[i].b_ps) : 0;
                ms += data[i].b_meter ? parseFloat(data[i].b_meter) : 0;

            }
            $(this).datagrid('reloadFooter', [{
                b_date: '合计',
                b_qty: qty.toFixed(1),
                b_ps: ps.toFixed(0),
                b_meter: ms.toFixed(0),
            }])
        }
    })

})


function getData() {

    console.log(
        'https://www.xdfznh.club/wxpadbe/execute/query/'
        + millName
        + "/call ClientStockdetail('"
        + Sdate + "','"
        + Edate + "','" + clientName +"','白坯发染厂')"
    );

    $.ajax({
        url: 'https://www.xdfznh.club/wxpadbe/execute/query/'
            + millName
            + "/call ClientStockdetail('"
            + Sdate + "','"
            + Edate + "','" + clientName +"','白坯发染厂')",

        type: 'get',
        dataType: 'json',
        success: function (data) {

            $('#waterdetai').datagrid('loadData', data);

        }
    })
}


//网格中显示进度条  '+tempval+'%
function formatterJD01(value, rec) {
    var tempval=rec.BillRow  ? parseFloat(rec.BillRow):0;
    var htmlstr = '<div class="easyui-progressbar progressbar" style="width: 110px; height: 20px;" value="'+tempval +'" text="'+tempval+'%">'+
        '<div class="progressbar-text" style="width: 110px; height: 20px; line-height: 20px;"></div>'+
        '<div class="progressbar-value" style="width: '+tempval+'%; height: 20px; line-height: 20px; ">'+
        '<div class="progressbar-text" style="width: 110px; height: 20px; line-height: 20px;"></div>'+
        '</div>'+
        '</div>';
    return htmlstr;
}

//获取浏览器地址参数
function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
    var r = window.location.search.substr(1).match(reg);  //匹配目标参数
    if (r != null) return unescape(r[2]);
    return null; //返回参数值
}

//获取浏览器地址参数（参数为中文）
function getRequest() {
    var url = window.location.search; //获取url中"?"符后的字串
    var theRequest = new Object();
    if (url.indexOf("?") != -1) {
        var str = url.substr(1);
        strs = str.split("&");
        for(var i = 0; i < strs.length; i ++) {
            //就是这句的问题
            theRequest[strs[i].split("=")[0]]=decodeURI(strs[i].split("=")[1]);
            //之前用了unescape()
            //才会出现乱码
        }
    }
    return theRequest;
}










